﻿#pragma warning disable 0168
using System;
using System.Linq;
using Celeriq.Client.Interfaces;
using Celeriq.WinService;

namespace Celeriq.HostConsole
{
	class Program
	{
		static void Main(string[] args)
		{
			var service = new PersistentService();
			service.Start();

			try
			{
				Console.WriteLine("Credentials: " + Tester.Credentials.Password);
			}
			catch (Exception ex)
			{
				Console.WriteLine(ex.ToString());
			}

			try
			{
				using (var factory = SystemCoreInteractDomain.GetFactory("localhost"))
				{
					var server = factory.CreateChannel();

					if (!server.IsValidCredentials(Tester.Credentials))
					{
						Console.WriteLine("Login failed for user.");
					}
					else
					{
						Console.WriteLine("Login Success.");
					}
				}
			}
			catch (Exception ex)
			{
				Console.WriteLine("An error occurred connecting to server.");
			}

			Console.WriteLine("Press <ENTER> to stop...");
			Console.ReadLine();
			service.Stop();

		}
	}
}
